package com.heima.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.SensitiveDto;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.service.SensitiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author chenshan
 */
@RestController
@RequestMapping("api/v1/sensitive")
public class SensitiveController {

    @Autowired
    private SensitiveService sensitiveService;

    /**
     * 分页条件查询敏感词
     * @param sensitiveDto 分页查询参数
     * @return ResponseResult
     */
    @PostMapping("list")
    public ResponseResult pageFindSensitives(@RequestBody SensitiveDto sensitiveDto) {
        return sensitiveService.pageFindSensitives(sensitiveDto);
    }

    /**
     * 添加敏感词
     * @param sensitive 敏感词信息
     * @return ResponseResult
     */
    @PostMapping("save")
    public ResponseResult saveSensitives(@RequestBody WmSensitive sensitive) {
        return sensitiveService.saveSensitives(sensitive);
    }

    /**
     * 修改敏感词
     * @param sensitive 敏感词信息
     * @return ResponseResult
     */
    @PostMapping("update")
    public ResponseResult updateSensitives(@RequestBody WmSensitive sensitive) {
        return sensitiveService.updateSensitives(sensitive);
    }

    /**
     * 删除敏感词
     * @param id 敏感词id
     * @return ResponseResult
     */
    @DeleteMapping("del/{id}")
    public ResponseResult delSensitivesById(@PathVariable String id) {
        return sensitiveService.delSensitivesById(id);
    }
}
